home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWWinDIB.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-08  |  3.2 KB  |  117 lines  |  [TEXT/MPS ]

  1. #ifndef FWWINDIB_H
  2. #define FWWINDIB_H
  3.  
  4. //========================================================================================
  5. //
  6. //    File:                FWWinDIB.h
  7. //    Release Version:    $ 1.0d11 $
  8. //
  9. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef FWSTDDEF_H
  14. #include "FWStdDef.h"
  15. #endif
  16.  
  17. #ifdef FW_BUILD_WIN
  18.  
  19. //========================================================================================
  20. //    Forward Class Declarations
  21. //========================================================================================
  22.  
  23. class FW_CLASS_ATTR FW_CColor;
  24. class FW_CLASS_ATTR FW_CWritableStream;
  25. class FW_CLASS_ATTR FW_CReadableStream;
  26.  
  27. //========================================================================================
  28. // class FW_CPrivWinDIB
  29. // A small set of utility functions to work with DIBs.
  30. //========================================================================================
  31.  
  32. class FW_CLASS_ATTR FW_CPrivWinDIB
  33. {
  34. public:
  35.  
  36.     enum
  37.     {
  38.         kWinBitmapFileSignature = 0x4D42        // "BM"
  39.     };
  40.     
  41.     DECLARE_HANDLE(HDIB);
  42.     
  43. #ifdef FW_BUILD_WIN32
  44.     typedef char* PixelBufferPtr;
  45. #endif
  46.  
  47. #ifdef FW_BUILD_WIN16
  48.     typedef char __huge* PixelBufferPtr;
  49. #endif
  50.  
  51.     // ----- Attributes
  52.     static unsigned long         GetPaletteSize(const BITMAPINFOHEADER* bmi);
  53.     static PixelBufferPtr        GetPixelBuffer(const BITMAPINFO* biPtr);
  54.     
  55.     static unsigned short        GetColorTable(HDIB dib, FW_CColor*& colors);
  56.         // NB: colors is allocated with "new" and should be freed!
  57.  
  58.     // ----- Conversion    
  59.     static HBITMAP                ConvertToBitmap(HDIB dib, HPALETTE hPal = NULL);
  60.     static HDIB                    ConvertFromBitmap(HBITMAP bitmapHandle, short bitDepth = 0, HPALETTE hPal = NULL);
  61.     
  62.     // ----- Palette
  63.     static HPALETTE                GetPalette(HDIB dib);
  64.     
  65.     // ----- Creation
  66.     static HDIB                    CreateDIB(short bitDepth, short width, short height,
  67.                                     short nbColors, const FW_CColor* colorTable,
  68.                                     const void* pixels = NULL);
  69.                                     
  70.     static HDIB                    CreateCopy(HDIB dib);
  71.     
  72.     // ----- Persistence
  73.     static void                    SaveToStream(const FW_CWritableStream& stream, HDIB dib, FW_Boolean bFileHeader);
  74.     static HDIB                    LoadFromStream(const FW_CReadableStream& stream, FW_Boolean bFileHeader);
  75.     
  76.     // ----- Memory
  77.     static     void                Free(HDIB dib);
  78.     
  79.     // ----- Implementation
  80. private:
  81.     static void                    PrivInitHeader(BITMAPINFOHEADER& header, int width, int height, int bitDepth);
  82.     
  83.     static void                    PrivGetColorInfo(
  84.                                     const BITMAPINFOHEADER& header,
  85.                                     int& bitDepth,        
  86.                                     int& colorCount,        // Will be 0 for 24-bit bitmap
  87.                                     int& paletteSize);
  88. };
  89.  
  90. //========================================================================================
  91. // class FW_CPrivWinBitmap
  92. // A small set of utility functions to work with device-dependent bitmaps
  93. //========================================================================================
  94.  
  95. class FW_CLASS_ATTR FW_CPrivWinBitmap
  96. {
  97. public:
  98.     static short GetColorDepth(HBITMAP hBitmap);
  99.  
  100.  
  101.     // CopyImage options
  102.     enum
  103.     {
  104.         kCrop,
  105.         kScale
  106.     };
  107.  
  108.     static void CopyImage(
  109.         HBITMAP hBmpDst, HPALETTE hPalDst, const RECT& rectDst,
  110.         HBITMAP hBmpSrc, HPALETTE hPalSrc, const RECT& rectSrc,
  111.         short options);
  112. };
  113.  
  114. #endif // FW_BUILD_WIN
  115.  
  116. #endif // FWWINDIB_H
  117.